import Vue from 'vue'
import Vuex from 'vuex'

const cartMesg = store => {
    // called when the store is initialized
    store.subscribe((mutation, state) => {
       
      console.log(mutation, state)
      window.localStorage.setItem('xxx-cart',JSON.stringify(state.cart))
      // called after every mutation.
      // The mutation comes in the format of `{ type, payload }`.
    })
  }

Vue.use(Vuex)

import state from './state'
import mutations from './mutations'
import getters from './getters'

const store =  new Vuex.Store ({
    strict:true,
    state,
    mutations,
    plugins: [cartMesg],
    getters
})
export default store